package com.rd.student.jike.class1.sunhao.day02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;

public class AverageName {
    public static void AN(LinkedList linkedList){
        ArrayList arrayList = new ArrayList();
        float averagename=0;
        for (int i=0;i<linkedList.size();i++){
            arrayList.add(((Student)linkedList.get(i)).age);
             averagename=averagename+((Student)linkedList.get(i)).age;
        }
        averagename=averagename/linkedList.size();

        System.out.println("平均年龄："+averagename+"岁");

        Collections.sort(arrayList);

        System.out.println(arrayList);

        HashMap hashMap=new HashMap();

        for (int i=0;i<arrayList.size();i++){

            for (int j=0;j<linkedList.size();i++){
                System.out.println("**************");
                int b=(int)arrayList.get(i);
                System.out.println("***********");

                int  a=((Student)linkedList.get(j)).age;

                System.out.println("*********");
                if (b==a){

                    hashMap.put(((Student)linkedList.get(j)).name,b);
                }
            }
        }
        System.out.println("按降序排列");

        for (int i=0;i<hashMap.size();i++) {
            
            System.out.println(hashMap.get(i));
        }
    }
    public static void NianLinngDuan(LinkedList linkedList){
        for (int i=0;i<linkedList.size();i++) {
            int p = ((Student) linkedList.get(i)).age;
            if (p > 0 && p <= 18) {
                int e = 1;
                if (e > 1) {
                    e++;
                    System.out.println((Student) linkedList.get(i));
                }
            }
            if (p > 18 && p <= 20) {
                if (p > 0 && p <= 18) {
                    int e = 1;
                    if (e > 1) {
                        e++;
                        System.out.println((Student) linkedList.get(i));
                    }
                }


                if (p > 20 && p <= 100) {
                    if (p > 0 && p <= 18) {
                        int e = 1;
                        if (e > 1) {
                            e++;
                            System.out.println((Student) linkedList.get(i));
                        }
                    }
                }

            }
        }
    }
}
